$(function () {
    init_tab();
});
function init_tab() {
    var settings = {
        url: ctx + "conversation/getNoticeDetail",
        pageSize: 10,
        sidePagination:"client",
        queryParams: function(params) {
            return {
                cConvSession:$("#noticeIdDetail").val().trim()
            };
        },
        columns: [ {
            field: 'cConvUsers',
            class: 'text-center',
            title: '客户',
            formatter:function (value, row, index) {
                var data = "";
                if(row!=""&&row!=null){
                    var type = row.cConvType;
                    var id = row.cConvId;
                    data = "<a href='javascript:void(0);' onclick='viewMycusDetail(this);' data-type='"+type+"' data-id='"+id+"'>"+value+"</a>";
                }
                return data;
            }
        },{
            field: 'cConvType',
            class: 'text-center',
            title: '资源类型',
            formatter:function (value, row, index) {
                var tname = "";
                if(value=="1"){
                    tname = "推广资源";
                }else if(value=="2"){
                    tname = "网校资源";
                }else if(value=="3"){
                    tname = "大资源";
                }else{
                    tname = "个人资源";
                }
                return tname;
            }
        }],
    };
    $JuXue.initTable('noticeDetaiTab', settings);
}

/**加载客户详情页面*/
function viewMycusDetail(btn) {
    var type = $(btn).attr("data-type");
    var ids = $(btn).attr("data-id");
    $("#customer_ids").val(ids);
    $("#customer_type").val(type);
    $.post(ctx+"myCustomer/loadCustomerDetail",{type:type},function (r) {
        $("#myCustomer-modal").empty().append(r).modal('show');
    });
}

/**导出会话通知的人**/
function expordSession(btn){
    var session = $("#noticeIdDetail").val();
    if (session == "" ){$JuXue.n_danger("获取资源失败");}
    $(btn).attr("disabled","disabled");
    $.post(ctx+"conversation/exportSessionData",{ids:session}, function (r) {
        if (r.code === 0) {
            window.open("file/download?fileName=" + r.msg + "&delete=" + true);
        } else {
            $JuXue.n_danger("导出数据失败");
        }
    });
}
